package com.gxjtkyy.datadistributer.writer.rdbms.vo;

import com.gxjtkyy.datadistributer.writer.rdbms.config.DbRecordFilterConfig;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import lombok.NonNull;
import org.apache.commons.lang3.StringUtils;

public class DbTableSetting {
   private String targetTableName;
   private boolean updatable;
   private boolean columnCaseSensitive;
   private boolean dropWhenValueTooLarge;
   private boolean dropWhenCannotInsertNull;
   private boolean dropWhenValueLargeThanSpecifiedPrecision;
   private Set<String> keyColumns = new HashSet();
   private Map<String, String> comparableColumns = new HashMap();
   private Set<String> ignoredColumnsForUpdate = new HashSet();
   private Set<String> ignoredColumnsForInsert = new HashSet();
   private Map<String, String> columnDefaultValues = new HashMap();
   private List<DbRecordFilterConfig> dbRecordFilterConfigs = new ArrayList();

   public boolean isKeyColumn(@NonNull String columnName) {
      if (columnName == null) {
         throw new NullPointerException("columnName is marked non-null but is null");
      } else {
         return this.columnCaseSensitive ? this.keyColumns.contains(columnName) : this.keyColumns.contains(columnName.toUpperCase());
      }
   }

   public boolean isIgnoredColumnForInsert(@NonNull String columnName) {
      if (columnName == null) {
         throw new NullPointerException("columnName is marked non-null but is null");
      } else {
         return this.columnCaseSensitive ? this.ignoredColumnsForInsert.contains(columnName) : this.ignoredColumnsForInsert.contains(columnName.toUpperCase());
      }
   }

   public boolean isIgnoredColumnForUpdate(@NonNull String columnName) {
      if (columnName == null) {
         throw new NullPointerException("columnName is marked non-null but is null");
      } else {
         return this.columnCaseSensitive ? this.ignoredColumnsForUpdate.contains(columnName) : this.ignoredColumnsForUpdate.contains(columnName.toUpperCase());
      }
   }

   public String getValue(@NonNull String column, String rawValue) {
      if (column == null) {
         throw new NullPointerException("column is marked non-null but is null");
      } else if (StringUtils.isNotBlank(rawValue)) {
         return rawValue;
      } else {
         return this.columnCaseSensitive ? (String)this.columnDefaultValues.getOrDefault(column, rawValue) : (String)this.columnDefaultValues.getOrDefault(column.toUpperCase(), rawValue);
      }
   }

   public String getTargetTableName() {
      return this.targetTableName;
   }

   public boolean isUpdatable() {
      return this.updatable;
   }

   public boolean isColumnCaseSensitive() {
      return this.columnCaseSensitive;
   }

   public boolean isDropWhenValueTooLarge() {
      return this.dropWhenValueTooLarge;
   }

   public boolean isDropWhenCannotInsertNull() {
      return this.dropWhenCannotInsertNull;
   }

   public boolean isDropWhenValueLargeThanSpecifiedPrecision() {
      return this.dropWhenValueLargeThanSpecifiedPrecision;
   }

   public Set<String> getKeyColumns() {
      return this.keyColumns;
   }

   public Map<String, String> getComparableColumns() {
      return this.comparableColumns;
   }

   public Set<String> getIgnoredColumnsForUpdate() {
      return this.ignoredColumnsForUpdate;
   }

   public Set<String> getIgnoredColumnsForInsert() {
      return this.ignoredColumnsForInsert;
   }

   public Map<String, String> getColumnDefaultValues() {
      return this.columnDefaultValues;
   }

   public List<DbRecordFilterConfig> getDbRecordFilterConfigs() {
      return this.dbRecordFilterConfigs;
   }

   public void setTargetTableName(final String targetTableName) {
      this.targetTableName = targetTableName;
   }

   public void setUpdatable(final boolean updatable) {
      this.updatable = updatable;
   }

   public void setColumnCaseSensitive(final boolean columnCaseSensitive) {
      this.columnCaseSensitive = columnCaseSensitive;
   }

   public void setDropWhenValueTooLarge(final boolean dropWhenValueTooLarge) {
      this.dropWhenValueTooLarge = dropWhenValueTooLarge;
   }

   public void setDropWhenCannotInsertNull(final boolean dropWhenCannotInsertNull) {
      this.dropWhenCannotInsertNull = dropWhenCannotInsertNull;
   }

   public void setDropWhenValueLargeThanSpecifiedPrecision(final boolean dropWhenValueLargeThanSpecifiedPrecision) {
      this.dropWhenValueLargeThanSpecifiedPrecision = dropWhenValueLargeThanSpecifiedPrecision;
   }

   public void setKeyColumns(final Set<String> keyColumns) {
      this.keyColumns = keyColumns;
   }

   public void setComparableColumns(final Map<String, String> comparableColumns) {
      this.comparableColumns = comparableColumns;
   }

   public void setIgnoredColumnsForUpdate(final Set<String> ignoredColumnsForUpdate) {
      this.ignoredColumnsForUpdate = ignoredColumnsForUpdate;
   }

   public void setIgnoredColumnsForInsert(final Set<String> ignoredColumnsForInsert) {
      this.ignoredColumnsForInsert = ignoredColumnsForInsert;
   }

   public void setColumnDefaultValues(final Map<String, String> columnDefaultValues) {
      this.columnDefaultValues = columnDefaultValues;
   }

   public void setDbRecordFilterConfigs(final List<DbRecordFilterConfig> dbRecordFilterConfigs) {
      this.dbRecordFilterConfigs = dbRecordFilterConfigs;
   }

   public boolean equals(final Object o) {
      if (o == this) {
         return true;
      } else if (!(o instanceof DbTableSetting)) {
         return false;
      } else {
         DbTableSetting other = (DbTableSetting)o;
         if (!other.canEqual(this)) {
            return false;
         } else if (this.isUpdatable() != other.isUpdatable()) {
            return false;
         } else if (this.isColumnCaseSensitive() != other.isColumnCaseSensitive()) {
            return false;
         } else if (this.isDropWhenValueTooLarge() != other.isDropWhenValueTooLarge()) {
            return false;
         } else if (this.isDropWhenCannotInsertNull() != other.isDropWhenCannotInsertNull()) {
            return false;
         } else if (this.isDropWhenValueLargeThanSpecifiedPrecision() != other.isDropWhenValueLargeThanSpecifiedPrecision()) {
            return false;
         } else {
            label107: {
               Object this$targetTableName = this.getTargetTableName();
               Object other$targetTableName = other.getTargetTableName();
               if (this$targetTableName == null) {
                  if (other$targetTableName == null) {
                     break label107;
                  }
               } else if (this$targetTableName.equals(other$targetTableName)) {
                  break label107;
               }

               return false;
            }

            Object this$keyColumns = this.getKeyColumns();
            Object other$keyColumns = other.getKeyColumns();
            if (this$keyColumns == null) {
               if (other$keyColumns != null) {
                  return false;
               }
            } else if (!this$keyColumns.equals(other$keyColumns)) {
               return false;
            }

            label93: {
               Object this$comparableColumns = this.getComparableColumns();
               Object other$comparableColumns = other.getComparableColumns();
               if (this$comparableColumns == null) {
                  if (other$comparableColumns == null) {
                     break label93;
                  }
               } else if (this$comparableColumns.equals(other$comparableColumns)) {
                  break label93;
               }

               return false;
            }

            label86: {
               Object this$ignoredColumnsForUpdate = this.getIgnoredColumnsForUpdate();
               Object other$ignoredColumnsForUpdate = other.getIgnoredColumnsForUpdate();
               if (this$ignoredColumnsForUpdate == null) {
                  if (other$ignoredColumnsForUpdate == null) {
                     break label86;
                  }
               } else if (this$ignoredColumnsForUpdate.equals(other$ignoredColumnsForUpdate)) {
                  break label86;
               }

               return false;
            }

            label79: {
               Object this$ignoredColumnsForInsert = this.getIgnoredColumnsForInsert();
               Object other$ignoredColumnsForInsert = other.getIgnoredColumnsForInsert();
               if (this$ignoredColumnsForInsert == null) {
                  if (other$ignoredColumnsForInsert == null) {
                     break label79;
                  }
               } else if (this$ignoredColumnsForInsert.equals(other$ignoredColumnsForInsert)) {
                  break label79;
               }

               return false;
            }

            label72: {
               Object this$columnDefaultValues = this.getColumnDefaultValues();
               Object other$columnDefaultValues = other.getColumnDefaultValues();
               if (this$columnDefaultValues == null) {
                  if (other$columnDefaultValues == null) {
                     break label72;
                  }
               } else if (this$columnDefaultValues.equals(other$columnDefaultValues)) {
                  break label72;
               }

               return false;
            }

            Object this$dbRecordFilterConfigs = this.getDbRecordFilterConfigs();
            Object other$dbRecordFilterConfigs = other.getDbRecordFilterConfigs();
            if (this$dbRecordFilterConfigs == null) {
               if (other$dbRecordFilterConfigs != null) {
                  return false;
               }
            } else if (!this$dbRecordFilterConfigs.equals(other$dbRecordFilterConfigs)) {
               return false;
            }

            return true;
         }
      }
   }

   protected boolean canEqual(final Object other) {
      return other instanceof DbTableSetting;
   }

   public int hashCode() {
//      int PRIME = true;
      int result = 1;
      result = result * 59 + (this.isUpdatable() ? 79 : 97);
      result = result * 59 + (this.isColumnCaseSensitive() ? 79 : 97);
      result = result * 59 + (this.isDropWhenValueTooLarge() ? 79 : 97);
      result = result * 59 + (this.isDropWhenCannotInsertNull() ? 79 : 97);
      result = result * 59 + (this.isDropWhenValueLargeThanSpecifiedPrecision() ? 79 : 97);
      Object $targetTableName = this.getTargetTableName();
      result = result * 59 + ($targetTableName == null ? 43 : $targetTableName.hashCode());
      Object $keyColumns = this.getKeyColumns();
      result = result * 59 + ($keyColumns == null ? 43 : $keyColumns.hashCode());
      Object $comparableColumns = this.getComparableColumns();
      result = result * 59 + ($comparableColumns == null ? 43 : $comparableColumns.hashCode());
      Object $ignoredColumnsForUpdate = this.getIgnoredColumnsForUpdate();
      result = result * 59 + ($ignoredColumnsForUpdate == null ? 43 : $ignoredColumnsForUpdate.hashCode());
      Object $ignoredColumnsForInsert = this.getIgnoredColumnsForInsert();
      result = result * 59 + ($ignoredColumnsForInsert == null ? 43 : $ignoredColumnsForInsert.hashCode());
      Object $columnDefaultValues = this.getColumnDefaultValues();
      result = result * 59 + ($columnDefaultValues == null ? 43 : $columnDefaultValues.hashCode());
      Object $dbRecordFilterConfigs = this.getDbRecordFilterConfigs();
      result = result * 59 + ($dbRecordFilterConfigs == null ? 43 : $dbRecordFilterConfigs.hashCode());
      return result;
   }

   public String toString() {
      String var10000 = this.getTargetTableName();
      return "DbTableSetting(targetTableName=" + var10000 + ", updatable=" + this.isUpdatable() + ", columnCaseSensitive=" + this.isColumnCaseSensitive() + ", dropWhenValueTooLarge=" + this.isDropWhenValueTooLarge() + ", dropWhenCannotInsertNull=" + this.isDropWhenCannotInsertNull() + ", dropWhenValueLargeThanSpecifiedPrecision=" + this.isDropWhenValueLargeThanSpecifiedPrecision() + ", keyColumns=" + this.getKeyColumns() + ", comparableColumns=" + this.getComparableColumns() + ", ignoredColumnsForUpdate=" + this.getIgnoredColumnsForUpdate() + ", ignoredColumnsForInsert=" + this.getIgnoredColumnsForInsert() + ", columnDefaultValues=" + this.getColumnDefaultValues() + ", dbRecordFilterConfigs=" + this.getDbRecordFilterConfigs() + ")";
   }
}
